This application relates generally to systems for computer graphics. More specifically, the present invention includes a method and apparatus for improving the quality of images that include aliased pixels.
Computer systems (and related devices) typically create three-dimensional images using a sequence of stages known as a graphics pipeline. During early pipeline stages, images are modeled using a mosaic-like approach where each image is composed of a collection of individual points, lines and polygons. These points, lines and polygons are know as primitives and a single image may require thousands, or even millions, of primitives. Each primitive is defined in terms of its shape and location as well as other attributes, such as color and texture.
The primitives used in early pipeline stages are transformed, during a rasterization stage, into collections of pixels. The rasterization stage is often performed by a specialized graphics processor (in low-end systems, rasterization may be performed directly by the host processor) and the resulting pixels are stored in a device known as a frame buffer. A frame buffer is a memory device that includes individual memory locations for each pixel.
During the rasterization stage, the graphics processor renders each primitive into the frame buffer. The graphics processor accomplishes this task by determining which frame buffer memory locations are included within the bounds of each primitive. The included memory locations are then initialized to reflect the attributes of the primitive, including color and texture.
Textures are the visual or tactile surface characteristics and appearance of an object. Depicting texture in a realistic manner is an important part of making three-dimensional images believable and is usually done by mapping texture images onto the primitives within an image. This process is known as texture mapping.
To be realistic, the texture mapping process must be configured to account for varying distances within an image. Textures that appear realistic when applied to nearby objects must be adjusted before they are applied to more distant objects. In many cases, this is done by precomputing a series of images to represent a single texture at different distances. The first image has the highest resolution and covers the greatest pixel area. Each succeeding image has a lower resolution and covers a smaller pixel area. The graphics system dynamically selects the correct image from the series based on the distance to the eye point and viewing angle. The entire series is typically stored in a data structure known as a mipmap.
While effective, the use of mipmaps and other pre-filtered texture images does not entirely solve the problem of applying textures to represent varying distances. This follows because mipmaps are typically generated isotropically. Each succeeding image is a square that is half as tall and half as wide as the preceding image. Unfortunately, objects within images don""t scale isotropically. Instead, objects both narrow and lengthen as they move from near to far. An object that is square when viewed in the foreground will appear rectangular when it is viewed at a distance. This causes problems when textures are applied to distant objects. Textures that are chosen to match an object""s width may fall short of matching the object""s height. Conversely, textures that match an object""s height are often too wide for the object""s width.
This type of mismatch means that the texturing process must be reconfigured to avoid pixel aliasing. This is typically accomplished by using lower resolution textures that are correctly dimensioned for one direction. Unfortunately, this causes the textures to blur along a second, orthogonal direction. This blurring is the visual result of information that is lost during the texturing process.
Texturing is not the only time at which pixel aliasing is a cause for concern. In fact, pixel aliasing occurs for many reasons. Aliasing can occur, for example, wherever two primitives overlap or at the edge of a primitive. Within regions of overlap, pixels can be split between multiple primitives. Rendering a pixel based on the attributes of one of these primitives can cause the pixel to be incorrectly rendered for remaining primitives. Aliasing of this type often results in stair step or otherwise jagged boundaries between overlapping primitives.
The overall effect of pixel aliasing is a reduction in image quality. As a result, a number of antialiasing methods have been developed. These methods attempt to reduce the number of aliased pixels or render them in a way that hides their aliased nature. Unfortunately, most of these methods require specialized hardware support to execute efficiently. This makes these methods unavailable in systems that do not include the required hardware support. Most antialiasing methods are also applied on an whole image basis. This means that antialiasing is applied to an entire image, even where it is only required for a small portion. This can be inefficient and increase the time required to render complex images.
For these reasons, a need exists for improving the quality of images that include aliased pixels. This need is particularly important where mipmaps are constructed using isotropic scaling and particularly important for systems that do not provide specialized antialiasing hardware.
An embodiment of the present invention includes a method and apparatus for improving the quality of images that include aliased pixels. For the method of the present invention, one or more portions of an image are selected for antialiasing. The selection process is preferably tailored to choose the image portions where highly accurate rendering is most important. In a flight simulator, these image portions might include the depictions of other aircraft or targets. In other cases, it may be practical to select the entire image for processing.
Each selected portion is rendered into the frame buffer. The resolution used for this rendering is higher than the original resolution of the selected image portion. For example, an image portion that normally would occupy a sixteen by sixteen pixel grid might be rendered as a forty-eight by forty-eight grid of pixels.
After rendering each image portion is read back from the frame buffer into a texture memory or texture cache. The image portions are now treated as textures. Each textures is applied to a quadrilateral that is drawn orthogonally to the viewer in the frame buffer. The quadrilaterals are sized to match the normal resolution of the image portions. As a result, the textures (which are created at a higher resolution) must be filtered to fit their quadrilaterals. The texturing hardware performs this process using weighted averages of the pixels included in the textures. The overall result is that the quadrilaterals are supersampled from the original image. This improves antialiasing and ensures that the textures applied to the quadrilaterals are anisotropic to a degree that matches the image resize.
Advantages of the invention will be set forth, in part, in the description that follows and, in part, will be understood by those skilled in the art from the description herein. The advantages of the invention will be realized and attained by means of the elements and combinations particularly pointed out in the appended claims and equivalents.